package com.mdxx.xczd.db.dao;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

import com.mdxx.xczd.bean.FileBean;
import com.mdxx.xczd.utils.GsonUtil;

import java.util.ArrayList;
import java.util.List;

public class FileServerDAO extends ServerDAO {

	public FileServerDAO(Context context) {
		super(context);

	}

	@Override
	public List<FileBean> queryMulti(String sql) {
		List<FileBean> list = new ArrayList<FileBean>();
		SQLiteDatabase db = null;
		Cursor cursor;
		try {
			db = dbHelper.getWritableDatabase();
			cursor = db.rawQuery(sql, null);
			while (cursor.moveToNext()) {
				String file = cursor.getString(cursor.getColumnIndex("file"));
				FileBean fileBean = GsonUtil.jsonToBean(file, FileBean.class);
				list.add(fileBean);
			}
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			if (null != db) {
				db.close();
			}
		}
		return list;
	}

}
